package com.example.demo.zabbix.request.builder.trigger;

import com.example.demo.zabbix.request.BaseRequest;
import com.example.demo.zabbix.request.builder.request.RequestBuilder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * https://www.zabbix.com/documentation/4.0/manual/api/reference/trigger/deletedependencies
 */
public class TriggerDeleteDependenciesRequestBuilder extends RequestBuilder<List<Map<String,String>>> {
    public TriggerDeleteDependenciesRequestBuilder(String auth) {
        super("trigger.deleteDependencies", auth);
        baseRequest.setParams(new ArrayList<>());
    }

    public TriggerDeleteDependenciesRequestBuilder(Long id, String auth) {
        super("trigger.deleteDependencies", id, auth);
        baseRequest.setParams(new ArrayList<>());
    }


    public TriggerDeleteDependenciesRequestBuilder setParam(String triggerId){

        baseRequest.getParams().add(new HashMap<String,String>(){{
            put("triggerid", triggerId);
        }});
        return this;
    }

    public TriggerDeleteDependenciesRequestBuilder setParams(List<String> triggerIds){
        List<Map<String,String>> triggerMap = new ArrayList<>();
        for(String triggerId:triggerIds){
            triggerMap.add(new HashMap<String,String>(){{
                put("triggerid", triggerId);
            }});
        }
        baseRequest.getParams().addAll(triggerMap);
        return this;
    }
    @Override
    public BaseRequest<List<Map<String, String>>> builder() {
        return baseRequest;
    }
}
